<template>
  <div class="u-p-20">
    <el-card shadow="never">
      <div slot="header">
        <span>
          <b class="u-f-16">店铺列表</b>
        </span>
        <router-link :to="{ name: 'storeEdit' }" v-if="hasPerm('storeEdit')">
          <el-button type="danger" size="small" icon="el-icon-plus" class="u-right u-5mt" round>添加店铺</el-button>
        </router-link>
      </div>

      <el-form :inline="true" :model="queryForm" size="small" class="u-text-center">
        <el-form-item label="店铺状态">
          <el-select v-model="queryForm.store_status" clearable>
            <el-option label="全部" value></el-option>
            <el-option label="开启" value="1"></el-option>
            <el-option label="关闭" value="0"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="关键词">
          <el-input v-model="queryForm.keyword" placeholder="输入店铺名称查询" clearable></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="el-icon-search" @click="getPageData(true)">查询</el-button>
        </el-form-item>
      </el-form>

      <el-table :data="tableData" class="u-mt-10" v-viewer>
        <el-table-column label="序号" type="index" :index="getIndexNo" width="100"></el-table-column>
        <el-table-column label="店铺名称" prop="store_name"></el-table-column>
        <el-table-column label="店铺logo" width="100">
          <template slot-scope="scope">
            <el-image style="max-height:90px;max-width: 90px;" :src="scope.row.store_label"
              :data-src="scope.row.store_label" fit="cover" lazy></el-image>
          </template>
        </el-table-column>
        <el-table-column label="商家类型" prop="store_type_text"></el-table-column>
        <el-table-column label="商家法人" prop="real_name"></el-table-column>
        <el-table-column label="联系号码" prop="contact_phone"></el-table-column>
        <el-table-column label="店铺状态" prop="store_status_text">
          <template slot-scope="scope" v-if="hasPerm('storeStatus')">
            <el-switch v-model="scope.row.store_status" :active-value="1" :inactive-value="0" active-color="#13ce66"
              @change="handleStatus(scope.row.id, scope.row.store_status)"></el-switch>
          </template>
        </el-table-column>
        <el-table-column label="审核状态" prop="check_status_text"></el-table-column>
        <el-table-column label="是否自营" prop="is_own_shop_text"></el-table-column>
        <el-table-column label="店铺排序" prop="sort"></el-table-column>
        <el-table-column label="创建时间" prop="create_time" sortable></el-table-column>
        <el-table-column label="操作" width="120">
          <template slot-scope="scope">
            <el-button size="mini" type="text" @click="handleRoute(scope.row.id, 'storeEdit')"
              v-if="hasPerm('storeEdit')">编辑</el-button>
            <el-button size="mini" type="text" @click.native="handleDelete(scope.row.id)" v-if="hasPerm('storeDelBtn')">
              删除</el-button>
          </template>
        </el-table-column>
      </el-table>
      <div class="u-mt-20 u-text-center">
        <el-pagination background @size-change="handleSizeChange" @current-change="handlePageChange"
          :current-page="currentPage" :page-sizes="[10, 20, 30, 40, 50]" :page-size="limit"
          layout="total, sizes, prev, pager, next, jumper" :total="total"></el-pagination>
      </div>
    </el-card>
  </div>
</template>

<script>
import commonPage from "@/mixins/common-page";

export default {
  mixins: [commonPage],
  data() {
    return {
      apiName: "store",
      queryForm: {
        store_status: "",
        check_status: "1",
        keyword: "",
      },
    };
  },
};
</script>
